import axios from '@/utils/http';
import base from './base';

export default {
  // 反馈列表
  index(params) {
    return axios.get(
      `${base.sq}/feedbacks`,
      {
        params: {
          type: params.type,
          page: params.page,
        },
      },
    );
  },
  // 创建反馈
  create(params) {
    return axios.post(
      `${base.sq}/feedbacks`,
      {
        title: params.title,
        content: params.content,
        tag: params.type,
      },
    );
  },
  // 反馈展示
  show(params) {
    return axios.get(`${base.sq}/feedbacks/${params.feedbackId}`);
  },
  update(params) {
    return axios.put(
      `${base.sq}/feedbacks/${params.feedbackId}`,
      {
        state: params.state,
        reply: params.content,
      },
    );
  },
  // 回复
  reply(params) {
    return axios.post(
      `${base.sq}/feedbacks/${params.feedbackId}/reply`,
      {
        content: params.content,
        timestamp: params.timestamp,
        state: params.state,
      },
    );
  },
};
